﻿ 
<div class="form-horizontal" ms-controller="TKGL">
    <div style="margin: 0 80px;">
        <div>
            <ul class="clearfix" style="display: block;padding:0">
                <li class="add-item add-widthall">
                    <label class="add-item-label"><i>*</i>分类名称</label>
                    <div class="add-ic">
                        <input type="text" autofocus="autofocus" class="form-control  szhl_require" ms-duplex="modelData.TKFLName">
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label">描述</label>
                    <div class="add-ic">
                        <textarea ms-duplex="modelData.Remark" rows="2" class="span2 form-control"></textarea>
                    </div>
                </li>

            </ul>
        </div>
    </div>
</div>

<script>
    var tempmodel = avalon.define({
        $id: "TKGL",
        ColumnData: [],
        XMData: [],
        name: "题库分类",
        iswf: true,//是否属于流程表单
        inittemp: function (strId) { 
            if (strId) {
                //编辑加载数据
                $.getJSON('/API/VIEWAPI.ashx?Action=KSGL_GETKSGLTYPE', { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;  
                        setTimeout("ComFunJS.initForm()", 500)

                    }
                })
            } else {
                if (localStorage.getItem(pmodel.FormCode) && localStorage.getItem(pmodel.FormCode) != JSON.stringify(tempmodel.modelData.$model)) {//判断有没有未保存的表单
                    var tempdata = localStorage.getItem(pmodel.FormCode);//缓存表单数据
                    ComFunJS.winconfirm("系统检测到您未保存的数据,是否加载?", function () {
                        tempmodel.modelData = $.parseJSON(tempdata);
                        ComFunJS.initForm();
                    }, function () {
                        localStorage.removeItem(pmodel.FormCode);
                        ComFunJS.initForm();
                    })
                } else {
                    pmodel.isDraft = true;
                    ComFunJS.initForm();
                }

            }
        },//初始化
        modelData: { "TKFLName": "", "Remark": "" }, 
        SaveData: function (callback, dom) {
            if (!tempmodel.modelData.TKFLName) {
                top.ComFunJS.winwarning("请输入分类名称");
                $(dom).attr("disabled", false).find(".fa").hide();
                return false;
            } 
            $.post("/API/VIEWAPI.ashx?ACTION=KSGL_ADDTKFL", { P1: JSON.stringify(tempmodel.modelData.$model) }, function (result) {
                return callback.call(this, $.parseJSON(result));
            });
        } 
    });

    tempmodel.$watch("modelData.*", function (a, b) {
        if (!tempmodel.modelData.ID) {
            localStorage.setItem(pmodel.FormCode, JSON.stringify(tempmodel.modelData.$model));
        }
    })
</script>